package com.example.leave.domain.approval.service;

import com.example.leave.domain.approval.aggregate.ApprovalRule;
import com.example.leave.domain.approval.repo.ApprovalRuleRepo;
import com.example.leave.domain.leave.aggregate.valueObject.LeaveType;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @author lxh
 * @date 2020/11/27 上午10:07
 **/
@Service
public class ApprovalDomainService {
    private final ApprovalRuleRepo approvalRuleRepo;

    public ApprovalDomainService(ApprovalRuleRepo approvalRuleRepo) {
        this.approvalRuleRepo = approvalRuleRepo;
    }

    /**
     * 根据请假类型和请假时长匹配审批规则
     */
    public ApprovalRule getApprovalRule(LeaveType leaveType, int duration) {
        return approvalRuleRepo.findOne(leaveType, duration);
    }
}
